﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once

#include "GcmpModelInterface.h"
#include "Vector3d.h"
#include "DbDataSchema.h"
#include "IGraphicsNodeReference.h"
#include "GcmpApiDeclaration.h"
#include "INoElementIdDbObject.h"
#include "NdbDataSchema.h"

namespace gcmp {
    
    /// \brief 支持自定义指定点的捕捉类型
    SERIALIZABLE_ENUM_CLASS(SnapTypeForCustomPoint)
    {
        Invalid = -1,            ///< 不合法的捕捉
        Point = 0,               ///< 点捕捉
        EndPoint = 1,            ///< 端点
        MiddlePoint = 2,         ///< 中点捕捉
        CenterPoint = 3,         ///< 圆心点捕捉
        IntersectPoint = 4,      ///< 交点捕捉
        PerpendicularPoint = 5,  ///< 垂足点捕捉
        TangentPoint = 6,        ///< 切点捕捉
        CustomPoint = 7,         ///< 自定义捕捉类型
        Quadrants = 8            ///< 象限点捕捉类型
    };

    /// \brief 自定义近程点捕捉数据
    struct GCMP_MODEL_INTERFACE_EXPORT LocalCustomPointSnapData
    {
        /// \brief 构造自定义近程点捕捉数据
        /// 
        /// \param type 自定义点捕捉类型
        /// \param snapPos 捕捉点的三维坐标
        /// \param snapText 捕捉时显示的文字
        /// \param pGraphicsNode 捕捉时高亮的图形节点，可为空
        /// \param iconPath 捕捉图标的路径
        LocalCustomPointSnapData(SnapTypeForCustomPoint type, const Vector3d& snapPos, const std::wstring& snapText, const std::vector<GraphicsNodeId>& graphicsNodeIdPath, const std::wstring& iconPath);
        
        const Vector3d SnapPointPosition;                                           ///< 自定义捕捉点的三维坐标
        const std::wstring SnapShortPrompt;                                         ///< 捕捉时的短字符提示
        const std::vector<GraphicsNodeId> SnapHilightGraphicsNodeIdPath;            ///< 捕捉时高亮的图形节点的路径，用于创建GraphicsNodeReference，可设置为空
        const std::wstring SnapIconPath;                                            ///< 自定义捕捉的图标路径，不设置的话，默认显示为点捕捉
        SnapTypeForCustomPoint CustomPointSnapType;                           ///< 自定义捕捉的捕捉类型，用于捕捉过滤
    };

    class IGeometry;
    class IModelView;
    class IElement;
    class IDocument;
    
    /// \brief 元素捕捉行为接口
    class GCMP_MODEL_INTERFACE_EXPORT IElementSnapComponent : public INoElementIdDbObject
    {
        DEFINE_CAST_DERIVED(gcmp::IElementSnapComponent, gcmp::INoElementIdDbObject)

    public:
        /// \brief 生成简单的捕捉组件的实现，只能进行远程捕捉
        ///
        /// 远程捕捉时，根据已有的两个定位点，生成一条辅助直线，或者根据已有的三个定位点，生成一条辅助弧线
        /// \return OwnerPtr<IElementSnapComponent>  返回一个捕捉组件
        static OwnerPtr<IElementSnapComponent> CreateSimpleElementSnapComponent();

        /// \brief 生成空的捕捉组件的实现
        ///
        /// 没有具体的捕捉逻辑
        /// \return OwnerPtr<IElementSnapComponent>  返回一个捕捉组件
        static OwnerPtr<IElementSnapComponent> CreateNullElementSnapComponent();
        
        /// \brief 获得远程捕捉几何辅助线
        ///
        /// \return 一组用于远程捕捉的几何辅助线
        virtual std::vector<OwnerPtr<IGeometry>> GetRemoteSnappableGeometry(const IModelView * pModelView) const = 0;

        /// \brief 获得自定义近程捕捉点的数据
        /// 
        /// \param pModelView 当前视图
        /// \param snapDatas 自定义近程捕捉点的数据
        /// \return 
        virtual void GetLocalCustomPointSnapDatas(const IModelView* pModelView, std::vector<LocalCustomPointSnapData>& snapDatas) const = 0;
    };

}// namespace gcmp


